import {CameraAllList} from "@/common/customs/security";

export const addTableConfig = (MyTable) => {
  MyTable.columns = [
    {
      title: "序号",
      key: "id",
      width: 50,
      slot: "c-index",
    },
    {
      title: "摄像头名称",
      key: "cameraName",
      slot: "c-title",
      width: 100,
    },
    {
      title: "摄像头类别",
      key: "is_tt",
      width: 100,
      bordered: false,
      slot: "c-select",
      items: [
        {
          name: "天台",
          id: 1
        },
        {
          name: "异常人员监控",
          id: 2
        },
        {
          name: "其他",
          id: 3
        },
      ]
    },
    {
      title: "经度",
      key: "jd",
      width: 75,

    },
    {
      title: "纬度",
      key: "wd",
      width: 75,
    },
    {
      title: "宿舍楼号",
      key: "ssl",
      width: 70,
      slot: "c-number",
      bordered: false,
    },
    // {
    //   title: "在线状态",
    //   key: "status",
    //   width: 70,
    //   slot: "c-roles",
    //   type: {
    //     0: "hui",
    //     1: "lv"
    //   },
    //   option: {
    //     0: "离线",
    //     1: "在线",
    //   }
    // },
  ];
  MyTable.overWidth = 800;
  MyTable.pageSize = 12;
  MyTable.key = 'camera';
  MyTable.getDatas = async (searchVal) => {
    try {
      const api = new CameraAllList()
        .params({
          page: MyTable.pageConfig.current,
          page_size: MyTable.pageConfig.pageSize,
          ...MyTable.param,
        });
      await api.send();
      const {data} = await api.getDatas();
      await MyTable.setDatas(data.data, data.total);
    } catch (err) {
      console.log(err);
    }
  };
  MyTable.onSearch = (val) => {
    MyTable.getDatas(val);
  };
};
